package com.star.service;

import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * 返回排除的数
 * 项目名称：starcolor   
 * 类名称：MyCombine   
 * 类描述：   
 * 创建人：Ss-2Uncle
 * 创建时间�?016-7-28 下午7:07:56     
 * @version
 */
public class MyCombine {    
    public static void main(String[] args) throws Throwable {
    	String str="12593";
    	String s="1134";
    	
    	System.out.println(tws1s(s,str));
	    
    	}
    /**
     * 稳上一数
     * @Title: tws1s 
     * @Description: 
     * @return String   
     * @author Ss-2Uncle
     * @date 2017-1-6 下午5:35:18
     */
    public static int tws1s(String s,String tws1s)  {
    	char[] t=tws1s.toCharArray();
    	int i=0;
	    	for (char c : t) {
	    		if(s.indexOf(c)>=0){
	    			i++;
	    		}
			}
		return i;
    }
    /**
     * 分割字符
     * @Title: rsSplit 
     * @Description: 
     * @return String   
     * @author Ss-2Uncle
     * @date 2016-11-14 下午11:46:30
     */
    public static String rsSplit(String str,String type)  {
    	StringBuffer sf=new StringBuffer();
    	 String[] f=str.split("");
    	  int l = f.length;  
	        if (l > 0) {  
	            l--;  
	            for(int i=1; i<l; i++)  {  
	            	sf.append(f[i]).append(type);  
	            }  
	            sf.append(f[l]);  
	       }
		return sf.toString();
    }
    //复制公式
    public static String rsSplitF(String str,String type)  {
    	StringBuffer sf=new StringBuffer();
    	 String[] f=str.split("");
    	  int l = f.length;  
	        if (l > 0) {  
	           // l--;  
	            for(int i=1; i<l; i++)  {  
	            	sf.append(type.replace("A", f[i]));  
	            }  
	           // sf.append(f[l]);  
	       }
		return sf.toString();
    }
    /**
     * 不上4粒公共方�?
     * @Title: rs4 
     * @Description: 
     * @return List<String>   
     * @author Ss-2Uncle
     * @date 2016-11-13 上午12:46:25
     */
    public static List<String> rs4(String str)  {
    	
    	char[] chardata = str.toCharArray();//{ "4","5", "4","3","7","8","7","8","1","6"};
        int num = 4;
        String[] strArr=new String[chardata.length];
        for(int i = 0; i < strArr.length; i++) {
            strArr[i] = String.valueOf(chardata[i]);
        }
        List<List<String>> result = parade(Arrays.asList(strArr), num);
        String rs="";
        List<String> ls=new ArrayList<String>();
        for (List<String> l : result) {
            rs= l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", "");
            ls.add(rs);
        }
       //System.out.printf("total:%s\n", result.size());
		return ls;
    }
    /**
     * 
     * @Title: ws 
     * @Description: 
     * @return List<String>   
     * @author Ss-2Uncle
     * @date 2016-11-13 上午1:23:20
     */
    public static List<String> ws(String str,String type)  {
    	
    	char[] chardata = str.toCharArray();//{ "4","5", "4","3","7","8","7","8","1","6"};
        int num = 4;
        String[] strArr=new String[chardata.length];
        for(int i = 0; i < strArr.length; i++) {
            strArr[i] = String.valueOf(chardata[i]);
        }
        List<List<String>> result = parade(Arrays.asList(strArr), num);
        String rs="";
        List<String> ls=new ArrayList<String>();
        for (List<String> l : result) {
            rs= l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", "");
            ls.add(rs);
        }
       //System.out.printf("total:%s\n", result.size());
		return ls;
    }
    
    /**
     * 
     * @Title: rs 
     * @Description: 
     * @return List<String>   
     * @author Ss-2Uncle
     * @date 2016-7-28 下午7:41:06
     */
    public static List<String> rs()  {
        String[] data = { "4","5", "4","3","7","8","7","8","1","6"};
        int num = 4;
        List<List<String>> result = parade(Arrays.asList(data), num);
        String rs="";
        List<String> ls=new ArrayList<String>();
        for (List<String> l : result) {
            rs= l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", "");
            ls.add(rs);
        }
       //System.out.printf("total:%s\n", result.size());
		return ls;
    }
    
    
    public static List<String> rsx()  {
        String[] data = { "5","0", "3","8","3","8","5","0","1","6"};
        int num = 4;
        List<List<String>> result = parade(Arrays.asList(data), num);
        String rs="";
        List<String> ls=new ArrayList<String>();
        for (List<String> l : result) {
            //System.out.println(l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", ""));
            rs= l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", "");
            ls.add(rs);
        }
       //System.out.printf("total:%s\n", result.size());
		return ls;
    }
    public static List<String> rsxx()  {
    	String[] data = { "2","4", "5","6","5","6"};
    	int num = 4;
    	List<List<String>> result = parade(Arrays.asList(data), num);
    	String rs="";
    	List<String> ls=new ArrayList<String>();
    	for (List<String> l : result) {
    		//System.out.println(l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", ""));
    		rs= l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", "");
    		ls.add(rs);
    	}
    	//System.out.printf("total:%s\n", result.size());
    	return ls;
    }
    public static List<String> rsxxx()  {
    	String[] data = { "0","1", "2","3","4","5"};
    	int num = 4;
    	List<List<String>> result = parade(Arrays.asList(data), num);
    	String rs="";
    	List<String> ls=new ArrayList<String>();
    	for (List<String> l : result) {
    		//System.out.println(l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", ""));
    		rs= l.toString().replace(",", "").replace(" ", "").replace("[", "").replace("]", "");
    		ls.add(rs);
    	}
    	//System.out.printf("total:%s\n", result.size());
    	return ls;
    }
    //
    public static List<List<String>> parade(List<String> data, int num) {
        List<List<String>> result = new ArrayList<List<String>>();
        if (num == 1) { //只排�?��元素的时候（递归结束条件�?
            for (String s : data) {
                List<String> l = new ArrayList<String>();
                l.add(s);
                result.add(l); //每个元素分别保存到结果集
            }
            return result; //并返回结果集
        }
        for (int i=0; i<data.size(); i++) { //num>1，即排多个元素的时�?，循�?
            List<String> list = new ArrayList<String>(data);
            list.remove(i); //去掉当前循环的元素作为下次�?归的参数，即剩余的元素做递归
            List<List<String>> sub = parade(list, num-1); //递归调用
            for (List<String> l : sub) { //然后循环递归得到的结�?
                l.add(0, data.get(i)); //把当前元素排在每个结果的前面
                result.add(l); //并保存到结果�?
            }
        }

        return result; //�?��返回结果�?
    }
}